﻿<Window x:Class="PHPVHGUI.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    ResizeMode="CanMinimize" SizeToContent="WidthAndHeight"
    Title="PHP Vulnerability Hunter" 
    Style="{StaticResource WindowStyle}">
    <Grid>
        <Menu Height="20" VerticalAlignment="Top">
            <MenuItem Header="File" InputGestureText="">
                <MenuItem Header="Exit" Click="ExitMenuItem_Click" />
            </MenuItem>
            <MenuItem Header="Help" Click="HelpMenuItem_Click"></MenuItem>
        </Menu>
        <Border Style="{StaticResource BorderStyle}" Margin="0,20,0,0">
            <Grid Margin="4">
                <Grid.Resources>
                    <Style TargetType="TextBox">
                        <Setter Property="Margin" Value="3" />
                        <Setter Property="Height" Value="24" />
                        <Setter Property="VerticalContentAlignment" Value="Center" />
                    </Style>
                </Grid.Resources>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <!-- Row 1 -->
                <StackPanel Grid.Row="0">
                    <Label Grid.Row="0" Grid.Column="0" Content="Analysis Mode" />
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <RadioButton Content="Hybrid Analysis" 
                                     IsChecked="{Binding HybridAnalysis,Mode=TwoWay}" />
                        <RadioButton Content="Static Analysis" 
                                     IsChecked="{Binding StaticAnalysis,Mode=TwoWay}"/>
                    </StackPanel>
                </StackPanel>

                <!-- General Settings -->
                <Grid Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="180" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.Resources>
                        <Style TargetType="Label">
                            <Setter Property="FontWeight" Value="Normal" />
                        </Style>
                    </Grid.Resources>
                    <Label Grid.Row="0" Grid.Column="0" Content="General" FontWeight="Bold" />
                    <Label Grid.Row="1" Grid.Column="0" Content="Host"
                           Visibility="{Binding HybridAnalysisVisibility}" />
                    <TextBox Grid.Row="1" Grid.Column="1" 
                             Text="{Binding Config.Server,Mode=TwoWay}" 
                             TextChanged="TextBox_TextChanged"
                             Visibility="{Binding HybridAnalysisVisibility}" >
                        <TextBox.ToolTip>
                            <TextBlock>The host name or IP address of the target server. Usually set to localhost.</TextBlock>
                        </TextBox.ToolTip>
                    </TextBox>
                    <!-- Row 3 -->
                    <Label Grid.Row="2" Grid.Column="0" Content="Port"
                       Visibility="{Binding HybridAnalysisVisibility}"/>
                    <TextBox Grid.Row="2" Grid.Column="1" x:Name="PortTextBox"
                         Visibility="{Binding HybridAnalysisVisibility}">
                        <TextBox.Text>
                            <Binding Path="Config.Port" Mode="TwoWay" 
                                 ValidatesOnExceptions="True"
                                 UpdateSourceTrigger="PropertyChanged" />
                        </TextBox.Text>
                        <TextBox.ToolTip>
                            <TextBlock>The port of the target server. Usually set to 80.</TextBlock>
                        </TextBox.ToolTip>
                    </TextBox>

                    <!-- Row 4 -->
                    <Label Grid.Row="3" Grid.Column="0" Content="Local Webroot" />
                    <TextBox Grid.Row="3" Grid.Column="1" 
                         Text="{Binding Config.WebRoot,Mode=TwoWay}">
                        <TextBox.ToolTip>
                            <TextBlock>The absolute local path to the server web root.</TextBlock>
                        </TextBox.ToolTip>
                    </TextBox>
                    <Button Content="Browse" Grid.Row="3" Grid.Column="2" Height="22" Width="90" 
                        Click="WebrootBrowseButton_Click" />

                    <!-- Row 5 -->
                    <Label Grid.Row="4" Grid.Column="0" Content="Apps (Comma Separated)" />
                    <TextBox Grid.Row="4" Grid.Column="1" x:Name="AppsTextBox"
                         Text="{Binding Config.AppPathsString,Mode=TwoWay}" />

                    <!-- Row 6 -->
                    <Label Grid.Row="5" Grid.Column="0" Content="Connection Timeout (ms)"
                       Visibility="{Binding HybridAnalysisVisibility}"/>
                    <TextBox Grid.Row="5" Grid.Column="1" x:Name="TimeoutTextBox"
                         Visibility="{Binding HybridAnalysisVisibility}">
                        <TextBox.Text>
                            <Binding Path="Config.Timeout" Mode="TwoWay" 
                                 UpdateSourceTrigger="PropertyChanged"
                                 ValidatesOnExceptions="True" />
                        </TextBox.Text>
                    </TextBox>
                </Grid>               

                <!-- Scan Plugins -->
                <StackPanel Grid.Row="0" Grid.RowSpan="2" Grid.Column="1" Margin="8,0,0,0"
                            x:Name="ScanModeStackPanel"
                            HorizontalAlignment="Left"
                            Visibility="{Binding HybridAnalysisVisibility}">
                    <Label Content="Scan Plugins" />
                    <CheckBox Content="Arbitrary Command Execution"
                              IsChecked="{Binding Config.CommandScan,Mode=TwoWay}" />
                    <CheckBox Content="Arbitrary File Change/Rename/Delete"
                              IsChecked="{Binding Config.FileScan,Mode=TwoWay}" />
                    <CheckBox Content="Local File Inclusion/Arbitrary Read"
                              IsChecked="{Binding Config.LFIScan,Mode=TwoWay}" />
                    <CheckBox Content="Arbitrary PHP Execution"
                              IsChecked="{Binding Config.ArbitraryPHPScan,Mode=TwoWay}" />
                    <CheckBox Content="SQL Injection"
                              IsChecked="{Binding Config.SQLScan,Mode=TwoWay}" />
                    <CheckBox Content="Dynamic Function Call/Class Instantiation"
                              IsChecked="{Binding Config.DynamicScan,Mode=TwoWay}" />
                    <CheckBox Content="Reflected Cross-site Scripting"
                              IsChecked="{Binding Config.XSSScan,Mode=TwoWay}" />
                    <CheckBox Content="Open Redirect"
                              IsChecked="{Binding Config.OpenRedirect,Mode=TwoWay}" />
                    <CheckBox Content="Full Path Disclosure"
                              IsChecked="{Binding Config.PathDisclosure,Mode=TwoWay}" />
                </StackPanel>

                <StackPanel Grid.Row="2" Grid.RowSpan="3" Grid.Column="0" HorizontalAlignment="Left"
                            Orientation="Horizontal" Margin="0,8,0,0">
                    <!-- Options -->
                    <StackPanel>
                        <Label Content="Options" />
                        <CheckBox Click="ScanAllCheckBox_Click"
                                  Content="Scan all apps in webroot"
                                  IsChecked="{Binding Config.AllApps,Mode=TwoWay}" />
                        <CheckBox Content="Open vulnerability report viewer"
                                  IsChecked="{Binding Config.RunViewer,Mode=TwoWay}" />
                        <CheckBox Content="Create discovery report"
                                  IsChecked="{Binding Config.DiscoveryReport,Mode=TwoWay}"
                                  Visibility="{Binding HybridAnalysisVisibility}"/>
                        <CheckBox Content="Dump all http messages"
                                  IsChecked="{Binding Config.DumpMessages,Mode=TwoWay}"
                                  Visibility="{Binding HybridAnalysisVisibility}"/>
                        <CheckBox Content="Beep on alert"
                                  IsChecked="{Binding Config.BeepOnAlert,Mode=TwoWay}"/>
                        <CheckBox Content="Log Console"
                                  IsChecked="{Binding Config.LogConsole,Mode=TwoWay}"/>
                    </StackPanel>
                    
                    <!-- Code Coverage-->
                    <StackPanel Margin="16,0,0,0"
                                Visibility="{Binding HybridAnalysisVisibility}">
                        <Label Content="Code Coverage" />
                        <RadioButton Content="None" GroupName="Code Coverage"
                                     IsChecked="{Binding Config.CodeCoverageNone,Mode=TwoWay}" />
                        <RadioButton Content="Normal" GroupName="Code Coverage"
                                     IsChecked="{Binding Config.CodeCoverageNormal,Mode=TwoWay}" />
                        <RadioButton Content="High Accuracy (slow)" GroupName="Code Coverage"
                                     IsChecked="{Binding Config.CodeCoverageHigh,Mode=TwoWay}" />
                    </StackPanel>
                </StackPanel>

                <!-- Toolstrip -->
                <StackPanel Grid.Row="3" Grid.Column="1"  
                            Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right">
                    <!--<Button Content="Test" Click="TestButton_Click" />-->
                    <Button Content="Repair" Click="RepairButton_Click" />
                    <Button Content="Scan" Click="StartButton_Click" />
                </StackPanel>                
            </Grid>
        </Border>
        
    </Grid>    
</Window>
